package ch6;

import java.util.Scanner;

public class Zuoye6 {//如果斐波拉切数列的前N项，N由用户输入。

    //    斐波拉切数列的定义是前两个是1，后面的每一个是前面的两个和
//，比如N是5,则输出结果是1,1,2,3,5
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入位数：");
        int n = input.nextInt();
        int a = 1, b = 1, c;
        if (n >= 3) {
            System.out.print(a + "  " + b + "  ");
            for (int i = 1; i <= n - 2; i++) {
                c = a + b;
                a = b;
                b = c;
                System.out.print(c + "  ");
            }
        }
        System.out.println("输入错误");
    }
}